def resolv_snap_cmd(cmd:str):
    area=r"(?P<area>电信|电二|联通|网通|)"
    # qq=r"(?P<qq>\d{5,10}|\[CQ:at,qq=\d{5,10}\])"
    qq = r"((?P<qq>\d{5,10})|\[CQ:at,qq=(?P<qq_at>\d{5,10})\])"
    nickname = r"(?P<nickname_with_brace>[\(（].+[）\)])"
    alter = r"(?P<alter>.*)"
    conds=[]
    conds.append("(?P<head>截图)"+area+"(?P<alter>魅力红人|等级红人|荣誉红人|车神红人|宠物战力|珍宝红人|多宠天梯|幸运红人|跨服幸运赛|大宝达人|二宝达人|拉力总RL|拉力红人|辉煌总积分|辉煌之路|星光红人|车队荣誉|赛季战勋|竞技红人|冠军红人|成就红人|回馈红人|火线红人|淘汰赛红人|车队总荣誉|战勋红人|进阶改装|后花园红人|钻皇红人|皇族红人|情侣贵族|车队贵族|红包达人|人气红人|火力红人|宝石红人|恩爱红人|情侣红人|名师红人|舞蹈红人|改装红人|养鱼红人|鲜花红人|酷币红人|日魅力红人|日火力红人|日赠送红人|周魅力红人|月魅力红人|日喇叭红人|周喇叭红人|日表白红人|周表白红人|日祝福红人|周祝福红人)")
    conds.append("(?P<head>截图|查询)"+area+nickname+alter)
    conds.append("(?P<head>截图|查询)"+area+qq+alter)
    conds.append("(?P<head>截图|查询)"+area+alter)
    conds.append("(?P<special_cmd>本周活动)")

    import re
    for i,cond in enumerate(conds):
        ret =re.match(cond,cmd)
        if ret == None:
            continue
        flag=True
        res = ret.groupdict()
        if 'area' in res and res['area'] == '':
            res['area'] = "电信"
        if 'qq' in res and res['qq'] == None:
            res['qq'] = res['qq_at']
        if i == 0:
            ans = res['head'] + res['area'] + res['alter']
        elif i == 1:
            ans = res['head'] + res['area'] + res['nickname_with_brace'] + res['alter']
        elif i == 2:
            ans = res['head'] + res['area'] + res['qq'] + res['alter']
        elif i == 3:
            ans = res['head'] + res['area'] + "{asker_qq}" + res['alter']
        elif i == 4:
            ans = res['special_cmd']
        res['ans'] = ans
        return res
#         print(r"""cmd={}
# cond={}
# res={}
# """.format(cmd,cond,res,ans))
    return None


if __name__ == '__main__':
    import re
    cmd = "昵称设置123456（别名）"
    pattern = r"昵称设置(?P<qq>\d{5,10})[\(（](?P<nick>.+)[\)）]"
    ret = re.match(pattern, cmd)
    res = ret.groupdict()
    print(res)
    exit()


    cmds=[]
    cmds.append("截图联通")
    cmds.append("截图联通幸运红人")
    cmds.append("截图联通（呆呆）")
    cmds.append("截图联通（呆呆）伴侣")
    cmds.append("截图联通892132762")
    cmds.append("截图联通[CQ:at,qq=892132762]")
    cmds.append("截图联通892132762车队")
    cmds.append("截图联通[CQ:at,qq=892132762]车队")
    cmds.append("截图")
    cmds.append("截图幸运红人")
    cmds.append("截图（呆呆）")
    cmds.append("截图（呆呆）伴侣")
    cmds.append("截图892132762")
    cmds.append("截图[CQ:at,qq=892132762]")
    cmds.append("截图892132762车队")
    cmds.append("截图[CQ:at,qq=892132762]车队")
    cmds.append("本周活动")
    for cmd in cmds:
        res = resolv_snap_cmd(cmd)
        print("cmd={}\nres={}\n".format(cmd,res))
    exit()
        